package edu.spbsu.nonsm00th.computgeom.sort.impl;

import edu.spbsu.nonsm00th.algorithms.sort.Comparator;
import edu.spbsu.nonsm00th.model.D2;
import edu.spbsu.nonsm00th.model.enums.Ratio;
import edu.spbsu.nonsm00th.util.Precondition;

/**
 * Cartesian comparator realization. Cartesian coordinates lexicographic comparator.
 *
 * @author mbuzdov
 */
@Deprecated
public class ComparatorD2Cartesian implements Comparator<D2> {

    public Ratio compare(final D2 a, final D2 b) {
        Precondition.argsNotNull(a, b);

        if (a.getX() > b.getX()) {
            return Ratio.GREATER;
        }
        if (a.getX() == b.getX()) {
            if (a.getY() > b.getY()) {
                return Ratio.GREATER;
            }
            if (a.getY() == b.getY()) {
                return Ratio.EQUAL;
            }
            return Ratio.LESS;
        }
        return Ratio.LESS;
    }

}
